package cn.tiasen.helloworld.adapters;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

import cn.tiasen.helloworld.R;
import cn.tiasen.helloworld.vo.AppInfo;

public class MobileGuardHomeAdapter extends BaseAdapter {

    private List<AppInfo> appInfos;
    private Context context;

    public MobileGuardHomeAdapter(Context context,List<AppInfo> appInfos){
        this.context = context;
        this.appInfos = appInfos;
    }

    @Override
    public int getCount() {
        return appInfos.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        if(convertView == null){
            convertView = View.inflate(context, R.layout.mobile_guard_item,null);

        }

        ImageView icon = convertView.findViewById(R.id.iv_icon);
        TextView title = convertView.findViewById(R.id.tv_title);

        icon.setImageDrawable(appInfos.get(position).getIcon());

        title.setText(appInfos.get(position).getName());
        return convertView;
    }
}
